package com.dsjy.yf.address.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * @author whj
 * @version 1.0
 * @date 2021-03-11 15:14
 */
@Component
public class UserUtil {
    @Autowired
    private SimpleGrantedAuthority simpleGrantedAuthority;

    public Boolean isAdmin() {
        return SecurityContextHolder.getContext().getAuthentication().getAuthorities()
                .contains(simpleGrantedAuthority);
    }
}
